#ifndef __MAIN_H__
#define __MAIN_H__


#define UART1_TX_Pin_Mode											P1M7
#define UART1_TX_Select_Pin										0x17

#define UART1_RX_Pin_Mode											P2M0
#define UART1_RX_Select_Pin										0x20




/**
 * IO definitions
 *
 * define access restrictions to peripheral registers
 */
#define     __I     volatile const   /*!< defines 'read only' permissions     */
#define     __O     volatile         /*!< defines 'write only' permissions    */
#define     __IO    volatile         /*!< defines 'read / write' permissions  */

/*!< Signed integer types  */
typedef   signed char     int8_t;
typedef   signed short    int16_t;
typedef   signed long     int32_t;

/*!< Unsigned integer types  */
typedef unsigned char     uint8_t;
typedef unsigned short    uint16_t;
typedef unsigned long     uint32_t;

/*!< STM8Lx Standard Peripheral Library old types (maintained for legacy purpose) */

//typedef int32_t  s32;
//typedef int16_t s16;
//typedef int8_t  s8;

//typedef uint32_t  u32;
//typedef uint16_t u16;
//typedef uint8_t  u8;


//typedef enum {FALSE = 0, TRUE = !FALSE} bool;

typedef enum {RESET = 0, SET = !RESET} FlagStatus, ITStatus, BitStatus, BitAction;

typedef enum {DISABLE = 0, ENABLE = !DISABLE} FunctionalState;
#define IS_FUNCTIONAL_STATE(STATE) (((STATE) == DISABLE) || ((STATE) == ENABLE))

typedef enum {ERROR = 0, SUCCESS = !ERROR} ErrorStatus;

#define U8_MAX     (255)
#define S8_MAX     (127)
#define S8_MIN     (-128)
#define U16_MAX    (65535u)
#define S16_MAX    (32767)
#define S16_MIN    (-32768)
#define U32_MAX    (4294967295uL)
#define S32_MAX    (2147483647)
#define S32_MIN    (-2147483648uL)



void task_1ms(void);
void task_10ms(void);
void task_20ms(void);
void task_100ms(void);	
void task_500ms(void);
void task_1s(void);

void CLK_Configuration(void);
void Delay_ms(unsigned int fui_i);
void Delay_2Us(unsigned int fui_i);


#endif


